package client;

import java.io.IOException;

import client.Message;
import client.ServerConnector;
import client.Strings;


public class ServerMessages {
	ServerConnector connector;
	Message mes;
	
	public ServerMessages() throws IOException {
		connector = new ServerConnector("localhost", 8001);
		connector.connect();
		mes = new Message();
	}
	public String initForum(String superAdminUser, String SuperAdminPass) throws IOException{
		return connector.send(mes.createMessage(Strings.INIT_FORUM, superAdminUser , SuperAdminPass));
	}
	public String addForum(String forumtitle, String managerID) throws IOException{
		return connector.send(mes.createMessage(Strings.ADD_FORUM , forumtitle , managerID));
	}
	
	public String showForums() throws IOException{
		return connector.send(mes.createMessage(Strings.SHOW_FORUMS));
	}
        
        public String showForum(String forumID) throws IOException{
		return connector.send(mes.createMessage(Strings.SHOW_SUBFORUMS , forumID));
	}
	
       public String showPost(String postID) throws IOException{
		return connector.send(mes.createMessage(Strings.SHOW_MESSAGES , postID));
	}
                
        public String showAllUsers() throws IOException{
		return connector.send(mes.createMessage(Strings.SHOW_SYSTEM_USERS));
	}
                
	public String login(String username, String password , String forumID) throws IOException{
		return connector.send(mes.createMessage(Strings.LOG_IN , username , password , forumID));
	}
        public String logout() throws IOException{
		return connector.send(mes.createMessage(Strings.LOGOUT));
	}
                
	
	public String register(String username, String password , String forumID) throws IOException{
		return connector.send(mes.createMessage(Strings.REGISTER , username , password , forumID));
	}
	
        public String showSubForum(String forumID) throws IOException{
		return connector.send(mes.createMessage(Strings.SHOW_TOPICS , forumID));
	}
                
	public String newsubforum(String name, String parentID, String forumAdmin) throws IOException{
		return connector.send(mes.createMessage(Strings.ADD_SUBFORUM , name , parentID, forumAdmin));
	}
	
	public String newMessage(String title, String desc, String subforumid) throws IOException{
		return connector.send(mes.createMessage(Strings.ADD_TOPIC , title , desc , subforumid));
	}
	
	public String newReply(String content, String postID) throws IOException{
		return connector.send(mes.createMessage(Strings.ADD_REPLY , content , postID));
	}
	
	public void exit() throws IOException {
		connector.disconnect();
	}
	public String showForumUsers(String forumID) throws IOException {
		return connector.send(mes.createMessage(Strings.SHOW_FORUM_USERS , forumID));
	}

}
